package WaiBao;

import java.util.Arrays;

public class WangWeiXing {
    public static void main(String[] args) {
        String[] name = {"闫佳乐(班长)", "张笑笑(副班长)", "小李(学习委员)", "李志奇(组织委员)", "张大大", "王祖蓝", "包贝尔", "叶祖新", "李泽楷", "李旭", "王佳旭", "立法还",
                "法海", "白娘子", "燕子", "大雁", "张雪峰", "林挑挑", "王境泽", "王凯", "王多鱼", "扛把子", "王嘉尔", "周二类", "李凯旭", "李泽浩", "赵翔宇", "黄广招",
                "王悦", "王伟鑫(组织委员)"};//考生本人:王伟鑫(组织委员)
        int[] age = {20, 20, 20, 21, 20, 21, 21,20,20, 19, 18, 18, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 21, 20, 18, 20, 20, 21, 21};//考生年龄：21

        double[] yang1 = {79, 74, 85, 80, 81, 69, 78, 99, 60, 84, 94, 87, 85, 79, 74, 68, 69, 79, 96, 88, 92, 91, 95, 85, 75, 74, 76, 89, 88, 95};
        double[] yang2 = {84, 85, 88, 65, 78, 87, 87, 69, 60, 80, 90, 67, 87, 75, 85, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 75, 72, 84, 97};
        double[] yang3 = {86, 85, 71, 65, 89, 75, 69, 69, 80, 60, 93, 87, 85, 85, 65, 68, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 95};


        double weixing1;//代表每个学生的总分
        double weixing2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            weixing1 = yang1[i] + yang2[i] +yang3[i];
//            weixing2 = (weixing1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + weixing1);
//            System.out.println(name[i] + "的平均分为:" + weixing2);
//        }


        double moli1 = 0, moli2 = 0;
        double[] juhua = new double[30];
//        for (int i = 0; i < 30; i++) {
//            moli1 = yang1[i] + yang2[i] + yang3[i];
//            moli2 = ( moli1 * 1.0) / 3;
//            juhua[i] = moli2;
//        }
//
//        for (int i = 0; i < juhua.length - 1; i++) {
//            for (int j = 0; j <juhua.length - i - 1; j++) {
//                if (juhua[j] < juhua[j + 1]) {
//                    double temp = juhua[j];
//                    juhua[j] =juhua[j + 1];
//                    juhua[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(juhua[i]);
//        }


        double ganbu1 = 0,ganbu2 = 0, ganbu3 = 0;//计算每门课的平均分
        double crocus1 = 0, crocus2 = 0, crocus3 = 0;//计算每门课标准差
        double shuxue1 = 0, shuxue2 = 0, shuxue3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i <yang1.length; i++) {
            sum2+=yang1[i];
        }
        ganbu1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+ganbu1);
        double Sum = 0;
        for (int i = 0; i < yang2.length; i++) {
            Sum+=yang2[i];
        }
        ganbu2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+ganbu2);
        double sum = 0;
        for (int i = 0; i <yang3.length; i++) {
            sum+=yang3[i];
        }
        ganbu3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+ganbu3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < yang1.length; i++) {
            c1+= (yang1[i] -ganbu1)*(yang1[i] - ganbu1);
        }
        crocus1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ crocus1);

        for (int i = 0; i <yang2.length; i++) {
            c2+= (yang2[i] -ganbu2)*(yang2[i] - ganbu2);
        }
        crocus2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ crocus2);

        for (int i = 0; i < yang3.length; i++) {
            c3+= (yang3[i] - ganbu3)*(yang3[i] -ganbu3);
        }
        crocus3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+ crocus3);
////
        Arrays.sort(yang1);
        Arrays.sort(yang2);
        Arrays.sort(yang3);
        shuxue1 =( yang1[14]+yang1[15])*1.0/2;
        shuxue2 =( yang2[14]+yang2[15])*1.0/2;
        shuxue3 =( yang3[14]+yang3[15])*1.0/2;
        System.out.println("分析化学的中位数为:"+shuxue1);
        System.out.println("线性代数的中位数为:"+shuxue2);
        System.out.println("有机化学学的中位数为:"+shuxue3);




    }
}
